package com.edu.exam.enums.curriculum.questionbank;

/**
 * 审批状态枚举
 *
 * @author System
 * @version 1.0
 * @since 2025-11-15
 */
public enum QuestionApprovalStatus {
    /**
     * 待审批
     */
    PENDING("PENDING", "待审批"),

    /**
     * 审批中
     */
    IN_PROGRESS("IN_PROGRESS", "审批中"),

    /**
     * 已批准
     */
    APPROVED("APPROVED", "已批准"),

    /**
     * 已拒绝
     */
    REJECTED("REJECTED", "已拒绝"),

    /**
     * 已取消
     */
    CANCELLED("CANCELLED", "已取消"),

    /**
     * 不需要审批
     */
    NOT_REQUIRED("NOT_REQUIRED", "不需要审批");

    private final String code;
    private final String description;

    QuestionApprovalStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据代码获取审批状态
     *
     * @param code 代码
     * @return 审批状态，找不到时返回默认值NOT_REQUIRED
     */
    public static QuestionApprovalStatus fromCode(String code) {
        for (QuestionApprovalStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return NOT_REQUIRED;
    }
}